//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#include <bulverde.h>

#define CKEN_ADV		__REG( CLK_BASE_PHYSICAL + CKEN_OFFSET )

#define IDBR_ADV		__REG( I2C_BASE_PHYSICAL + IDBR_OFFSET )
#define ICR_ADV			__REG( I2C_BASE_PHYSICAL + I2CR_OFFSET )
#define ISR_ADV			__REG( I2C_BASE_PHYSICAL + ISR_OFFSET )
#define ISAR_ADV		__REG( I2C_BASE_PHYSICAL + ISAR_OFFSET )
#define CFR_ADV			__REG( I2C_BASE_PHYSICAL + CFR_OFFSET )

#define GPDR0_ADV		__REG( GPIO_BASE_PHYSICAL + GPDR0_OFFSET )
#define GAFR0_L_ADV		__REG( GPIO_BASE_PHYSICAL + GAFR0_L_OFFSET )
#define GAFR0_U_ADV	        __REG( GPIO_BASE_PHYSICAL + GAFR0_U_OFFSET )
#define GFER0_ADV		__REG( GPIO_BASE_PHYSICAL + GFER0_OFFSET )
#define ICMR_ADV		__REG( INTC_BASE_PHYSICAL + ICMR_OFFSET )

#define CKEN14_I2C_ADV		(1<<14)

#define GPDR2_ADV		__REG( GPIO_BASE_PHYSICAL + GPDR2_OFFSET )
#define GAFR2_L_ADV		__REG( GPIO_BASE_PHYSICAL + GAFR2_L_OFFSET )
#define GAFR2_U_ADV        	__REG( GPIO_BASE_PHYSICAL + GAFR2_U_OFFSET )
#define GFER2_ADV		__REG( GPIO_BASE_PHYSICAL + GFER2_OFFSET )

        
#define GPDR3_ADV          __REG( GPIO_BASE_PHYSICAL + GPDR3_OFFSET )
#define GAFR3_L_ADV        __REG( GPIO_BASE_PHYSICAL + GAFR3_L_OFFSET )
#define GAFR3_U_ADV        __REG( GPIO_BASE_PHYSICAL + GAFR3_U_OFFSET )
#define GFER3_ADV          __REG( GPIO_BASE_PHYSICAL + GFER3_OFFSET )
        
        
#define GPCR2_ADV          __REG( GPIO_BASE_PHYSICAL + GPCR2_OFFSET )
       
#define GPCR0_ADV          __REG( GPIO_BASE_PHYSICAL + GPCR0_OFFSET )

#define GPSR2_ADV          __REG( GPIO_BASE_PHYSICAL + GPSR2_OFFSET )

#define GPSR0_ADV          __REG( GPIO_BASE_PHYSICAL + GPSR0_OFFSET )

#define ICR_START		(1<<0)
#define ICR_STOP		(1<<1)
#define ICR_ACKNAK		(1<<2)
#define ICR_TB			(1<<3)
#define ICR_SCLE		(1<<5)
#define ICR_IUE			(1<<6)
#define ICR_ALDIE		(1<<12)

#define ISR_ITE			(1<<6)
#define ISR_IRF                 (1<<7)

void I2CInit(void);
char I2CRead(char devid, char address);
void I2CWrite(char devid, char address, char data);
